package br.ufmg.ubicomp.droidguide.eventservice.management;

import java.util.Collection;
import java.util.logging.Logger;

import br.ufmg.ubicomp.droidguide.common.DroidGuideEntity;
import br.ufmg.ubicomp.droidguide.common.DroidGuideUser;
import br.ufmg.ubicomp.droidguide.context.Context;
import br.ufmg.ubicomp.droidguide.eventservice.enums.EventState;
import br.ufmg.ubicomp.droidguide.eventservice.event.EventCriteria;
import br.ufmg.ubicomp.droidguide.eventservice.event.UserEvent;

/**
 * DroidGuide Event Service
 * @author Waldir Pires
 *
 */
public class EventService {

	private static EventService theService;
	private DroidGuideEntity profile;
	private Context context;
	
	public static EventService getInstance()
	{
		if (theService == null)
		{
			theService = new EventService();
		}
		return theService;
	}
	
	private EventService() {
		
	}
	
	public DroidGuideEntity getProfile() {
		return profile;
	}

	public void setProfile(DroidGuideEntity profile) {
		this.profile = profile;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	public Collection<UserEvent> queryEventsOfInterest(DroidGuideUser user, DroidGuideEntity profile, Context context)
	{		
		return null;
	}
	
	public Collection<UserEvent> querySpecificEvents(EventCriteria criteria)
	{
		return null;
	}

	public Collection<UserEvent> listAllEvents()
	{
		return null;
	}
	
	public void notifyEventConsumed(UserEvent event, DroidGuideUser user)
	{
		event.setState(EventState.CONSUMED);
	}
	
	public void handleEvent(UserEvent event)
	{
		Logger logger = Logger.getLogger(getClass().getSimpleName());
		logger.info("Incomming notification: " + event);
		EventManager manager = EventManager.getInstance();
		manager.addEvent(event);		
	}

}